package com.example.jimanguang.Entity;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.util.UUID;

/*
12.1
 */
@MappedSuperclass//JPA注解，用于实体类的父类，被标注的父类不是完整的实体类,不会映射到数据库而是把其属性映射到子类的数据库列。因此被标注的类不能再标注@Entity或@Table
public class BaseEntity {
    @Id
    @GeneratedValue(generator = "uuid2")
    @GenericGenerator(name = "uuid2", strategy = "uuid2")
//@GeneratedValue注解中的"generator"属性要与@GenericGenerator注解中name属性一致，strategy属性表示hibernate的主键生成策略
    @Column(columnDefinition = "BINARY(16)")
    protected UUID id;

    protected BaseEntity() {

    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }
}
